//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using System.Windows;

namespace OpenLS.UI
{
    class PreviousState
    {
        public PreviousState(DependencyObject d, Style trigger)
        {
            foreach (Setter setter in trigger.Setters)
            {
                propertyValues.Add(new PropertyValue(setter.Property, d.ReadLocalValue(setter.Property)));
            }


        }
        public void Restore(DependencyObject d)
        {
            foreach (PropertyValue v in propertyValues)
            {
                d.SetValue(v.Property, v.Value);
            }
        }

        readonly List<PropertyValue> propertyValues = new List<PropertyValue>();
        struct PropertyValue
        {
            public PropertyValue(DependencyProperty prop, object value)
            {
                _prop = prop;
                _value = value;
            }
            private readonly DependencyProperty _prop;

            public DependencyProperty Property
            {
                get { return _prop; }
            }
            private readonly object _value;

            public object Value
            {
                get { return _value; }
            }


        }
    }
}
